package homework.day06;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * 聊天室客户端类
 *
 * @author Luka
 * @date 2021/06/02 20:26
 **/
public class Client1 {
    private Socket socket;
    public Client1() {
        try {
            System.out.println("正在连接服务器...");
            socket = new Socket("localhost",8088);
            System.out.println("连接服务器成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start(){
        try {
            Scanner sc = new Scanner(System.in);
            OutputStream out = socket.getOutputStream();
            OutputStreamWriter osw = new OutputStreamWriter(out,"UTF-8");
            BufferedWriter bw = new BufferedWriter(osw);
            PrintWriter pw = new PrintWriter(bw,true);

            while (true){
                pw.println("input");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Client client = new Client();
        client.start();
    }
}